package com.lb.jwitter.action;


import java.text.DateFormat; 
import java.text.SimpleDateFormat; 
import java.util.ArrayList; 
import java.util.Collection; 
import java.util.Date; 
import java.util.GregorianCalendar;

import com.lb.jwitter.service.ConditionReport; 
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import com.lb.jwitter.util.Message; 
import java.util.Collections; 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
import java.util.List; 
import java.util.Map; 

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import com.lb.jwitter.util.ApplicationContextProvider; 
 import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.lb.jwitter.service.TblQLDTTXAThongBaoTuyenSinh;
import com.lb.jwitter.service.TblQLDTTXAThongBaoTuyenSinhService;

import com.lb.jwitter.service.TblQLDTTXADMKhoaHoc;
import com.lb.jwitter.service.TblQLDTTXADMKhoaHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAThongBaoTuyenSinhAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    private int page; 
    public int getPage() { return page; }

    private int pages; 
    public int getPages() { return pages; }

    private String dataString; 
    public String getDataString() { return dataString; }

    private String idList; 
    public String getIdList() { return idList; } 
    public void setIdList(String idList) { this.idList = idList; }

    private Message msg; 
    public Message getMsg() { return msg; }

    private Long id; 
    public Long getId() {
       return id;
 }

    public void setId(Long id) {
       this.id = id;
 }

    private String ten; 
    public void setTen(String ten) {
       this.ten = ten;
 }

    public String getTen() {
       return ten;
 }

    private String hinhAnh; 
    public void setHinhAnh(String hinhAnh) {
       this.hinhAnh = hinhAnh;
 }

    public String getHinhAnh() {
       return hinhAnh;
 }

    private String noiDung; 
    public void setNoiDung(String noiDung) {
       this.noiDung = noiDung;
 }

    public String getNoiDung() {
       return noiDung;
 }

    private String thoiGianBatDau; 
    public void setThoiGianBatDau(String thoiGianBatDau) {
       this.thoiGianBatDau = thoiGianBatDau;
 }

    public String getThoiGianBatDau() {
       return thoiGianBatDau;
 }

    private String thoiGianKetThuc; 
    public void setThoiGianKetThuc(String thoiGianKetThuc) {
       this.thoiGianKetThuc = thoiGianKetThuc;
 }

    public String getThoiGianKetThuc() {
       return thoiGianKetThuc;
 }

    private String ngayCongBoKetQua; 
    public void setNgayCongBoKetQua(String ngayCongBoKetQua) {
       this.ngayCongBoKetQua = ngayCongBoKetQua;
 }

    public String getNgayCongBoKetQua() {
       return ngayCongBoKetQua;
 }

    private String ngayHoanTatThuTuc; 
    public void setNgayHoanTatThuTuc(String ngayHoanTatThuTuc) {
       this.ngayHoanTatThuTuc = ngayHoanTatThuTuc;
 }

    public String getNgayHoanTatThuTuc() {
       return ngayHoanTatThuTuc;
 }

    private int khoaHocId; 
    public void setKhoaHocId(int khoaHocId) {
       this.khoaHocId = khoaHocId;
 }

    public int getKhoaHocId() {
       return khoaHocId;
 }

    private TblQLDTTXAThongBaoTuyenSinh tblQLDTTXAThongBaoTuyenSinh; 
    public TblQLDTTXAThongBaoTuyenSinh getTblQLDTTXAThongBaoTuyenSinh () {
        return this.tblQLDTTXAThongBaoTuyenSinh ;
 }

    private Collection<TblQLDTTXAThongBaoTuyenSinh> tblQLDTTXAThongBaoTuyenSinhs; 
    public Collection<TblQLDTTXAThongBaoTuyenSinh> getTblQLDTTXAThongBaoTuyenSinhs() {
        return this.tblQLDTTXAThongBaoTuyenSinhs; 
      } 

    private TblQLDTTXAThongBaoTuyenSinhService tblQLDTTXAThongBaoTuyenSinhService; 

    private Collection<TblQLDTTXADMKhoaHoc> tblQLDTTXADMKhoaHocs; 
    public void setTblQLDTTXADMKhoaHocs(Collection<TblQLDTTXADMKhoaHoc> tblQLDTTXADMKhoaHocs) {
            this.tblQLDTTXADMKhoaHocs = tblQLDTTXADMKhoaHocs; 
    }
    public Collection<TblQLDTTXADMKhoaHoc> getTblQLDTTXADMKhoaHocs()
    {
    	return tblQLDTTXADMKhoaHocs;
    }

    private TblQLDTTXADMKhoaHocService tblQLDTTXADMKhoaHocService; 

	private int preUpdate(Message msg, TblQLDTTXAThongBaoTuyenSinh obj ){ 
        msg.setPreMessage_b(true); 
        msg.setPreMessage_s("success"); 
        return 1; 
    } 
	private int postUpdate(Message msg, TblQLDTTXAThongBaoTuyenSinh obj ){ 
        msg.setPostMessage_b(true); 
        msg.setPostMessage_s("success"); 
        return 1; 
    } 
  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
 public String update() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "sua")){ 
        return "noprivilege"; 
    }           
    
    tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient");
    
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
        msg = new Message(); 
        tblQLDTTXAThongBaoTuyenSinh = tblQLDTTXAThongBaoTuyenSinhService.gettblQLDTTXAThongBaoTuyenSinh(new Long(id)); 
        tblQLDTTXAThongBaoTuyenSinh.setTen(ten); 
        tblQLDTTXAThongBaoTuyenSinh.setHinhAnh(hinhAnh); 
        tblQLDTTXAThongBaoTuyenSinh.setNoiDung(noiDung); 

        
        DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); 
        Date dd = df.parse(thoiGianBatDau); 
        GregorianCalendar c = new GregorianCalendar(); 
        c.setTime(dd);
        XMLGregorianCalendar d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
         tblQLDTTXAThongBaoTuyenSinh.setThoiGianBatDau(d); 

        dd = df.parse(thoiGianKetThuc); 
        c.setTime(dd);
        d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
         tblQLDTTXAThongBaoTuyenSinh.setThoiGianKetThuc(d); 
         

        dd = df.parse(ngayCongBoKetQua); 

        c.setTime(dd);
        d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
         tblQLDTTXAThongBaoTuyenSinh.setNgayCongBoKetQua(d); 
         
        dd = df.parse(ngayHoanTatThuTuc); 
        c.setTime(dd);
        d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
         tblQLDTTXAThongBaoTuyenSinh.setNgayHoanTatThuTuc(d); 
         
        tblQLDTTXAThongBaoTuyenSinh.setKhoaHocId(tblQLDTTXADMKhoaHocService.gettblQLDTTXADMKhoaHoc(new Long(khoaHocId))); 
        preUpdate(msg,tblQLDTTXAThongBaoTuyenSinh); 
       if (msg.isPreMessage_b()) 
       { 
           tblQLDTTXAThongBaoTuyenSinhService.updatetblQLDTTXAThongBaoTuyenSinh(tblQLDTTXAThongBaoTuyenSinh); 
           postUpdate(msg, tblQLDTTXAThongBaoTuyenSinh); 
           if (msg.isPostMessage_b() == false) 
           { 
               return Action.ERROR; 
           } 
       }else{ 
           return Action.ERROR; 
       } 

       if(pageSize == 0){ 
           pageSize = 20; 
       } 
        if(page == 0){ 
           page =1; 
       } 
      tblQLDTTXAThongBaoTuyenSinhs =       tblQLDTTXAThongBaoTuyenSinhService.findAlltblQLDTTXAThongBaoTuyenSinh(pageSize, page); 
      pages = tblQLDTTXAThongBaoTuyenSinhService.counttblQLDTTXAThongBaoTuyenSinhByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      dataString = ""; 
      dataString += "&id="; 
      dataString += "&ten="; 
      dataString += "&hinhAnh="; 
      dataString += "&noiDung="; 
      dataString += "&thoiGianBatDau="; 
      dataString += "&thoiGianKetThuc="; 
      dataString += "&ngayCongBoKetQua="; 
      dataString += "&ngayHoanTatThuTuc="; 
      dataString += "&khoaHocId="; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
         System.out.println("Loi Update tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
         e.printStackTrace(); 
         return Action.ERROR; 
 } 
 } 
  public String form() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 

    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "xem")){ 
        return "noprivilege"; 
    }           
    tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient");
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
       
    
    if(pageSize == 0){ 
            pageSize = 20; 
        } 
        if(page == 0){ 
            page =1; 
        } 
        tblQLDTTXAThongBaoTuyenSinhs =        tblQLDTTXAThongBaoTuyenSinhService.findAlltblQLDTTXAThongBaoTuyenSinh(pageSize, page); 
        pages = tblQLDTTXAThongBaoTuyenSinhService.counttblQLDTTXAThongBaoTuyenSinhByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      dataString = ""; 
      dataString += "&id="; 
      dataString += "&ten="; 
      dataString += "&hinhAnh="; 
      dataString += "&noiDung="; 
      dataString += "&thoiGianBatDau="; 
      dataString += "&thoiGianKetThuc="; 
      dataString += "&ngayCongBoKetQua="; 
      dataString += "&ngayHoanTatThuTuc="; 
      dataString += "&khoaHocId="; 
      tblQLDTTXADMKhoaHocs = tblQLDTTXADMKhoaHocService.findAlltblQLDTTXADMKhoaHoc(0, 0);
      Collections.reverse((List<?>) tblQLDTTXADMKhoaHocs);
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Form tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
  public String delete() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "xoa")){ 
        return "noprivilege"; 
    }           
    
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
    msg = new Message(); 

    List<String> ids = new ArrayList<String>(); 
    Collections.addAll(ids, idList.split(",")); 
    for(String id : ids){ 
        tblQLDTTXAThongBaoTuyenSinhService.deleteListtblQLDTTXAThongBaoTuyenSinh(ids); 
    } 
       if(pageSize == 0){ 
           pageSize = 20; 
       } 
        if(page == 0){ 
           page =1; 
       } 
      tblQLDTTXAThongBaoTuyenSinhs =       tblQLDTTXAThongBaoTuyenSinhService.findAlltblQLDTTXAThongBaoTuyenSinh(pageSize, page); 
      pages = tblQLDTTXAThongBaoTuyenSinhService.counttblQLDTTXAThongBaoTuyenSinhByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      dataString = ""; 
      dataString += "&id="; 
      dataString += "&ten="; 
      dataString += "&hinhAnh="; 
      dataString += "&noiDung="; 
      dataString += "&thoiGianBatDau="; 
      dataString += "&thoiGianKetThuc="; 
      dataString += "&ngayCongBoKetQua="; 
      dataString += "&ngayHoanTatThuTuc="; 
      dataString += "&khoaHocId="; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Delete tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 	private int preInsert(Message msg, TblQLDTTXAThongBaoTuyenSinh obj ){ 
        msg.setPreMessage_b(true); 
        msg.setPreMessage_s("success"); 
        return 1; 
    } 
	private int postInsert(Message msg, TblQLDTTXAThongBaoTuyenSinh obj ){ 
        msg.setPostMessage_b(true); 
        msg.setPostMessage_s("success"); 
        return 1; 
    } 
 public String insert() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "them")){ 
        return "noprivilege"; 
    }           
    
    tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient");
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
        msg = new Message(); 
        tblQLDTTXAThongBaoTuyenSinh = new TblQLDTTXAThongBaoTuyenSinh(); 
        tblQLDTTXAThongBaoTuyenSinh.setTen(ten); 
        tblQLDTTXAThongBaoTuyenSinh.setHinhAnh(hinhAnh); 
        tblQLDTTXAThongBaoTuyenSinh.setNoiDung(noiDung); 
        
       DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); 
       Date dd = df.parse(thoiGianBatDau); 
       GregorianCalendar c = new GregorianCalendar(); 
       c.setTime(dd);
       XMLGregorianCalendar d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
        tblQLDTTXAThongBaoTuyenSinh.setThoiGianBatDau(d); 

       dd = df.parse(thoiGianKetThuc); 
       c.setTime(dd);
       d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
        tblQLDTTXAThongBaoTuyenSinh.setThoiGianKetThuc(d); 
        

       dd = df.parse(ngayCongBoKetQua); 

       c.setTime(dd);
       d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
        tblQLDTTXAThongBaoTuyenSinh.setNgayCongBoKetQua(d); 
        
       dd = df.parse(ngayHoanTatThuTuc); 
       c.setTime(dd);
       d = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); 
        tblQLDTTXAThongBaoTuyenSinh.setNgayHoanTatThuTuc(d); 
        
        tblQLDTTXAThongBaoTuyenSinh.setKhoaHocId(tblQLDTTXADMKhoaHocService.gettblQLDTTXADMKhoaHoc(new Long(khoaHocId))); 
        preInsert(msg,tblQLDTTXAThongBaoTuyenSinh); 
       if (msg.isPreMessage_b()) 
       { 
           id = tblQLDTTXAThongBaoTuyenSinhService.createtblQLDTTXAThongBaoTuyenSinh(tblQLDTTXAThongBaoTuyenSinh); 
           postInsert(msg, tblQLDTTXAThongBaoTuyenSinh); 
           if (msg.isPostMessage_b() == false) 
           { 
               return Action.ERROR; 
           } 
       }else{ 
           return Action.ERROR; 
       } 
       tblQLDTTXAThongBaoTuyenSinh.setId(id); 
       if(pageSize == 0){ 
           pageSize = 20; 
       } 
        if(page == 0){ 
           page =1; 
       } 
      tblQLDTTXAThongBaoTuyenSinhs =       tblQLDTTXAThongBaoTuyenSinhService.findAlltblQLDTTXAThongBaoTuyenSinh(pageSize, page); 
      pages = tblQLDTTXAThongBaoTuyenSinhService.counttblQLDTTXAThongBaoTuyenSinhByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      dataString = ""; 
      dataString += "&id="; 
      dataString += "&ten="; 
      dataString += "&hinhAnh="; 
      dataString += "&noiDung="; 
      dataString += "&thoiGianBatDau="; 
      dataString += "&thoiGianKetThuc="; 
      dataString += "&ngayCongBoKetQua="; 
      dataString += "&ngayHoanTatThuTuc="; 
      dataString += "&khoaHocId="; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
         System.out.println("Loi Insert tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
         e.printStackTrace(); 
         return Action.ERROR; 
 } 
 } 
 	private int preSearch(Message msg, List<ConditionReport> cons ){ 
        msg.setPreMessage_b(true); 
        msg.setPreMessage_s("success"); 
        return 1; 
    } 
	private int postSearch(Message msg, List<ConditionReport> cons ){ 
        msg.setPostMessage_b(true); 
        msg.setPostMessage_s("success"); 
        return 1; 
    } 
 public String search() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "xem")){ 
        return "noprivilege"; 
    }           
    
    tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient");
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
        msg = new Message(); 
        List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
    if(id!= null && !id.equals(0)){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("id");
        con.setValue1(new Long(id));
        con.setOperator("eq");
        cons.add(con);	
    } 
    if(ten != null && !ten.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("ten");
        con.setValue1("%" + ten + "%");
        con.setOperator("like");
        cons.add(con);	
    } 
    if(hinhAnh != null && !hinhAnh.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("hinhAnh");
        con.setValue1("%" + hinhAnh + "%");
        con.setOperator("like");
        cons.add(con);	
    } 
    if(noiDung != null && !noiDung.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("noiDung");
        con.setValue1("%" + noiDung + "%");
        con.setOperator("like");
        cons.add(con);	
    } 
    if(thoiGianBatDau != null && !thoiGianBatDau.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("thoiGianBatDau");
        con.setValue1(thoiGianBatDau);
        con.setOperator("eq");
        con.setType("date");
        cons.add(con);	
    } 
    if(thoiGianKetThuc != null && !thoiGianKetThuc.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("thoiGianKetThuc");
        con.setValue1(thoiGianKetThuc);
        con.setOperator("eq");
        con.setType("date");
        cons.add(con);	
    } 
    if(ngayCongBoKetQua != null && !ngayCongBoKetQua.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("ngayCongBoKetQua");
        con.setValue1(ngayCongBoKetQua);
        con.setOperator("eq");
        con.setType("date");
        cons.add(con);	
    } 
    if(ngayHoanTatThuTuc != null && !ngayHoanTatThuTuc.equalsIgnoreCase("")){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("ngayHoanTatThuTuc");
        con.setValue1(ngayHoanTatThuTuc);
        con.setOperator("eq");
        con.setType("date");
        cons.add(con);	
    } 
    if(khoaHocId != 0 ){ 
        ConditionReport con = new ConditionReport(); 
        con.setCol("khoaHocId.id");
        con.setValue1(new Long(khoaHocId));
        con.setOperator("eq");
        cons.add(con);	
    } 
        preSearch(msg, cons); 
       if (msg.isPreMessage_b()) 
       { 
           if(pageSize == 0){ 
               pageSize = 20; 
           } 
            if(page == 0){ 
               page =1; 
           } 
           tblQLDTTXAThongBaoTuyenSinhs = tblQLDTTXAThongBaoTuyenSinhService.findtblQLDTTXAThongBaoTuyenSinhByCondition(cons,pageSize,page); 
           pages = tblQLDTTXAThongBaoTuyenSinhService.counttblQLDTTXAThongBaoTuyenSinhByCondition(cons)/pageSize + 1; 
           postSearch(msg, cons); 
           if (msg.isPostMessage_b() == false) 
           { 
               return Action.ERROR; 
           } 
       }else{ 
           return Action.ERROR; 
       } 
      dataString = ""; 
      dataString += "&id=" + id; 
      dataString += "&ten=" + ten; 
      dataString += "&hinhAnh=" + hinhAnh; 
      dataString += "&noiDung=" + noiDung; 
      dataString += "&thoiGianBatDau=" + thoiGianBatDau; 
      dataString += "&thoiGianKetThuc=" + thoiGianKetThuc; 
      dataString += "&ngayCongBoKetQua=" + ngayCongBoKetQua; 
      dataString += "&ngayHoanTatThuTuc=" + ngayHoanTatThuTuc; 
      dataString += "&khoaHocId=" + khoaHocId; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
         System.out.println("Loi Seach tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
         e.printStackTrace(); 
         return Action.ERROR; 
 } 
 } 
  public String editForm() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThongBaoTuyenSinh", "sua")){ 
        return "noprivilege"; 
    }           
    
    tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient");
    tblQLDTTXAThongBaoTuyenSinhService = (TblQLDTTXAThongBaoTuyenSinhService)context.getBean("tbl_QLDTTXA_ThongBaoTuyenSinhClient"); 
        tblQLDTTXAThongBaoTuyenSinh = tblQLDTTXAThongBaoTuyenSinhService.gettblQLDTTXAThongBaoTuyenSinh(new Long(id)); 
        tblQLDTTXADMKhoaHocs = tblQLDTTXADMKhoaHocService.findAlltblQLDTTXADMKhoaHoc(0, 0);
        Collections.reverse((List<?>) tblQLDTTXADMKhoaHocs);
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_ThongBaoTuyenSinh Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
